com.rscja.barcode

## Class BarcodeUtility

- java.lang.Object
- - com.rscja.barcode.BarcodeUtility

- All Implemented Interfaces:
    IBarcodeUtility

      public class BarcodeUtility
      extends java.lang.Object
      implements IBarcodeUtility

  条码操作类 barcode operate class 注意： Attention: 1、使用前请确认您的机器已安装键盘助手v1.9.0 之后的版本。 1. Confirm keyboardeumulator v1.9.0 has been installed before using.
  Author:
    zhoupin

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `BarcodeUtility.ModuleType`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ACTION_SCAN_KEYBOARD_HELPER_PARAM_RESPONSE`
    `static java.lang.String` | `SCANNER_BARCODE_1D` 1D是否已经开启
    `static java.lang.String` | `SCANNER_BARCODE_2D` 2D是否已经开启
    `static java.lang.String` | `SCANNER_BARCODENOTREPEAT` 条码是否重复显示
    `static java.lang.String` | `SCANNER_BROADCAST_ACTION` 接收扫描数据的广播ACTION
    `static java.lang.String` | `SCANNER_BROADCAST_EXTRA` 接收扫描数据的广播的extra数据
    `static java.lang.String` | `SCANNER_CONTINUOUS` 是否是连续扫描 Whether enable continuous scan
    `static java.lang.String` | `SCANNER_CONTINUOUS_INTREVALTIME` 连续扫描时间间隔
    `static java.lang.String` | `SCANNER_CONTINUOUSMODE` 是否启用了连续扫描模式
    `static java.lang.String` | `SCANNER_CONTINUOUSTIMEOUT` 连续扫描超时时间 continuous scanning overtime duration
    `static java.lang.String` | `SCANNER_ENDINDEX` 后面去掉多少个字符
    `static java.lang.String` | `SCANNER_ENTER` 是否启用回车
    `static java.lang.String` | `SCANNER_FAILUREBROADCAST` 扫描失败是否发送广播 Send broadcast when scanning failure.
    `static java.lang.String` | `SCANNER_FAILURESOUND` 扫描失败是否播放声音 whether playing notification when scanning failure.
    `static java.lang.String` | `SCANNER_FILTERCHARS` 条码数据需要过滤的字符串
    `static java.lang.String` | `SCANNER_FORMAT_BARCODE` 条码格式 0: Default 1: ASCII 2:GB2312 3:UTF8 4:Unicode 10:GBK, 11:GB18030 Barcode format 0: Default 1: ASCII 2:GB2312 3:UTF8 4:Unicode 10:GBK, 11:GB18030
    `static java.lang.String` | `SCANNER_ILLUMINATIONPOWERLEVEL` 4710 扫描头亮度等级
    `static java.lang.String` | `SCANNER_KEYBORADHELPER_OPEN` 键盘助手总开关是否已经打开
    `static java.lang.String` | `SCANNER_OUTPUTMODE` 数据接收方式 0:键盘模拟 1:剪切板 2:系统广播 ouput mode 0: virtual key 1: clipboard 2: broadcast
    `static java.lang.String` | `SCANNER_PREFIX` 条码前缀 barcode prefix.
    `static java.lang.String` | `SCANNER_RELEASESCAN` 松开扫描按键是否停止扫描 loose scanning button to stop scanning or not
    `static java.lang.String` | `SCANNER_SCANKEYCODE_1` 扫描按键值 scan key code.
    `static java.lang.String` | `SCANNER_SCANKEYCODE_3` 扫描按键值 scan key code.
    `static java.lang.String` | `SCANNER_SOUND` 扫描成功是否播放声音
    `static java.lang.String` | `SCANNER_STARTINDEX` 前面去掉多少个字符
    `static java.lang.String` | `SCANNER_SUFFIX` 条码后缀 barcode suffix.
    `static java.lang.String` | `SCANNER_TAB` 是否启用tab
    `static java.lang.String` | `SCANNER_TIMEOUT` 扫描超时 scanning time out.
    `static java.lang.String` | `SCANNER_VIBRATE` 是否启用震动 whether vibrating when scanning success

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close(android.content.Context context, BarcodeUtility.ModuleType modul)` 关闭指定功能 Switch off designated function
    `void` | `closeKeyboardHelper(android.content.Context context)` 关闭键盘助手功能总开关 Switch off main function switch of keyboardemulator
    `void` | `enableContinuousScan(android.content.Context context, boolean isContinuous)` 启用连续扫描 Enable continuous scan
    `void` | `enableEnter(android.content.Context context, boolean isEnter)` 是否启用回车 Whether enable Enter function
    `void` | `enablePlayFailureSound(android.content.Context context, boolean isFailureSound)` 扫描失败是否播放提示音 whether playing notification when scanning failure.
    `void` | `enablePlaySuccessSound(android.content.Context context, boolean isSuccessSound)` 是否播放成功的提示音 whether playing notification when scanning success.
    `void` | `enableTAB(android.content.Context context, boolean isTab)` 是否启用TAB Whether enable TAB function
    `void` | `enableVibrate(android.content.Context context, boolean isVibrate)` 扫描成功是否震动提示 whether vibrating when scanning success
    `void` | `filterCharacter(android.content.Context context, java.lang.String chars)` 过滤字符串 Filter charactor string
    `static BarcodeUtility` | `getInstance()` 获取条码操作实例 Acquire barcode operation Instance.
    `void` | `interceptTrimLeft(android.content.Context context, int num)` 截取左边字符串数量 Capture left side charactor string amount
    `void` | `interceptTrimRight(android.content.Context context, int num)` 截取右边字符串数量 Capture right side charactor string amount
    `void` | `open(android.content.Context context, BarcodeUtility.ModuleType modul)` 打开指定功能 Switch on designated function
    `void` | `openKeyboardHelper(android.content.Context context)` 打开键盘助手功能总开关 Switch on main function switch of keyboardemulator
    `void` | `setBarcodeEncodingFormat(android.content.Context context, int format)` 设置条码编码格式 Setup barcode coding format
    `void` | `setContinuousScanIntervalTime(android.content.Context context, int intervalTime)` 设置连续扫描间隔时间 Setup continuous scanning duration
    `void` | `setContinuousScanTimeOut(android.content.Context context, int timeOut)` 设置连续扫描超时时间 Setup continuous scanning overtime duration
    `void` | `setOutputMode(android.content.Context context, int mode)` 设置输出模式 Setup ouput mode
    `void` | `setParam_zebra(android.content.Context context, int paramId, int paramValue)` 设置斑马扫描头参数,扫描头上电之后设置一次即可,扫描头断电之后失效。(备注：键盘助手v2.2.0.3 之后的版本才支持)
    `void` | `setPrefix(android.content.Context context, java.lang.String prefix)` 设置前缀 Setup prefix
    `void` | `setReleaseScan(android.content.Context context, boolean enable)` 松开扫描按键是否停止扫描 loose scanning button to stop scanning or not
    `void` | `setScanFailureBroadcast(android.content.Context context, boolean enable)` 扫描失败是否发送广播 Send broadcast when scanning failure.
    `void` | `setScanOutTime(android.content.Context context, int time)` 设置超时时间 Setup overtime duration
    `void` | `setScanResultBroadcast(android.content.Context context, java.lang.String broadcastAction, java.lang.String extraName)` 设置接收扫描数据的广播 Setup broad cast of received scanning data
    `void` | `setSuffix(android.content.Context context, java.lang.String suffix)` 设置后缀 Setup suffix
    `void` | `startScan(android.content.Context context, BarcodeUtility.ModuleType modul)` 开始扫描 Start scanning
    `void` | `stopScan(android.content.Context context, BarcodeUtility.ModuleType modul)` 停止扫描 Stop scanning

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ACTION_SCAN_KEYBOARD_HELPER_PARAM_RESPONSE

          public static final java.lang.String ACTION_SCAN_KEYBOARD_HELPER_PARAM_RESPONSE

      See Also:
        Constant Field Values

    - #### SCANNER_RELEASESCAN

          public static final java.lang.String SCANNER_RELEASESCAN

      松开扫描按键是否停止扫描 loose scanning button to stop scanning or not
      See Also:
        Constant Field Values

    - #### SCANNER_BROADCAST_ACTION

          public static final java.lang.String SCANNER_BROADCAST_ACTION

      接收扫描数据的广播ACTION
      See Also:
        Constant Field Values

    - #### SCANNER_CONTINUOUS

          public static final java.lang.String SCANNER_CONTINUOUS

      是否是连续扫描 Whether enable continuous scan
      See Also:
        Constant Field Values

    - #### SCANNER_CONTINUOUS_INTREVALTIME

          public static final java.lang.String SCANNER_CONTINUOUS_INTREVALTIME

      连续扫描时间间隔
      See Also:
        Constant Field Values

    - #### SCANNER_FORMAT_BARCODE

          public static final java.lang.String SCANNER_FORMAT_BARCODE

      条码格式 0: Default 1: ASCII 2:GB2312 3:UTF8 4:Unicode 10:GBK, 11:GB18030 Barcode format 0: Default 1: ASCII 2:GB2312 3:UTF8 4:Unicode 10:GBK, 11:GB18030
      See Also:
        Constant Field Values

    - #### SCANNER_BARCODENOTREPEAT

          public static final java.lang.String SCANNER_BARCODENOTREPEAT

      条码是否重复显示
      See Also:
        Constant Field Values

    - #### SCANNER_BROADCAST_EXTRA

          public static final java.lang.String SCANNER_BROADCAST_EXTRA

      接收扫描数据的广播的extra数据
      See Also:
        Constant Field Values

    - #### SCANNER_SCANKEYCODE_3

          public static final java.lang.String SCANNER_SCANKEYCODE_3

      扫描按键值 scan key code.
      See Also:
        Constant Field Values

    - #### SCANNER_SCANKEYCODE_1

          public static final java.lang.String SCANNER_SCANKEYCODE_1

      扫描按键值 scan key code.
      See Also:
        Constant Field Values

    - #### SCANNER_FILTERCHARS

          public static final java.lang.String SCANNER_FILTERCHARS

      条码数据需要过滤的字符串
      See Also:
        Constant Field Values

    - #### SCANNER_FAILUREBROADCAST

          public static final java.lang.String SCANNER_FAILUREBROADCAST

      扫描失败是否发送广播 Send broadcast when scanning failure.
      See Also:
        Constant Field Values

    - #### SCANNER_BARCODE_1D

          public static final java.lang.String SCANNER_BARCODE_1D

      1D是否已经开启
      See Also:
        Constant Field Values

    - #### SCANNER_VIBRATE

          public static final java.lang.String SCANNER_VIBRATE

      是否启用震动 whether vibrating when scanning success
      See Also:
        Constant Field Values

    - #### SCANNER_SUFFIX

          public static final java.lang.String SCANNER_SUFFIX

      条码后缀 barcode suffix.
      See Also:
        Constant Field Values

    - #### SCANNER_TAB

          public static final java.lang.String SCANNER_TAB

      是否启用tab
      See Also:
        Constant Field Values

    - #### SCANNER_ENTER

          public static final java.lang.String SCANNER_ENTER

      是否启用回车
      See Also:
        Constant Field Values

    - #### SCANNER_ENDINDEX

          public static final java.lang.String SCANNER_ENDINDEX

      后面去掉多少个字符
      See Also:
        Constant Field Values

    - #### SCANNER_FAILURESOUND

          public static final java.lang.String SCANNER_FAILURESOUND

      扫描失败是否播放声音 whether playing notification when scanning failure.
      See Also:
        Constant Field Values

    - #### SCANNER_OUTPUTMODE

          public static final java.lang.String SCANNER_OUTPUTMODE

      数据接收方式 0:键盘模拟 1:剪切板 2:系统广播 ouput mode 0: virtual key 1: clipboard 2: broadcast
      See Also:
        Constant Field Values

    - #### SCANNER_SOUND

          public static final java.lang.String SCANNER_SOUND

      扫描成功是否播放声音
      See Also:
        Constant Field Values

    - #### SCANNER_TIMEOUT

          public static final java.lang.String SCANNER_TIMEOUT

      扫描超时 scanning time out.
      See Also:
        Constant Field Values

    - #### SCANNER_PREFIX

          public static final java.lang.String SCANNER_PREFIX

      条码前缀 barcode prefix.
      See Also:
        Constant Field Values

    - #### SCANNER_CONTINUOUSTIMEOUT

          public static final java.lang.String SCANNER_CONTINUOUSTIMEOUT

      连续扫描超时时间 continuous scanning overtime duration
      See Also:
        Constant Field Values

    - #### SCANNER_KEYBORADHELPER_OPEN

          public static final java.lang.String SCANNER_KEYBORADHELPER_OPEN

      键盘助手总开关是否已经打开
      See Also:
        Constant Field Values

    - #### SCANNER_CONTINUOUSMODE

          public static final java.lang.String SCANNER_CONTINUOUSMODE

      是否启用了连续扫描模式
      See Also:
        Constant Field Values

    - #### SCANNER_ILLUMINATIONPOWERLEVEL

          public static final java.lang.String SCANNER_ILLUMINATIONPOWERLEVEL

      4710 扫描头亮度等级
      See Also:
        Constant Field Values

    - #### SCANNER_STARTINDEX

          public static final java.lang.String SCANNER_STARTINDEX

      前面去掉多少个字符
      See Also:
        Constant Field Values

    - #### SCANNER_BARCODE_2D

          public static final java.lang.String SCANNER_BARCODE_2D

      2D是否已经开启
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getInstance

          public static BarcodeUtility getInstance()

      获取条码操作实例 Acquire barcode operation Instance.

    - #### open

          public void open(android.content.Context context,
                           BarcodeUtility.ModuleType modul)

      打开指定功能 Switch on designated function
      Specified by:
        `open` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `modul` - 功能模块

    - #### close

          public void close(android.content.Context context,
                            BarcodeUtility.ModuleType modul)

      关闭指定功能 Switch off designated function
      Specified by:
        `close` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `modul` - 功能模块

    - #### startScan

          public void startScan(android.content.Context context,
                                BarcodeUtility.ModuleType modul)

      开始扫描 Start scanning
      Specified by:
        `startScan` in interface `IBarcodeUtility`
      Parameters:
        `modul` - 功能模块

    - #### stopScan

          public void stopScan(android.content.Context context,
                               BarcodeUtility.ModuleType modul)

      停止扫描 Stop scanning
      Specified by:
        `stopScan` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `modul` - 功能模块

    - #### setOutputMode

          public void setOutputMode(android.content.Context context,
                                    int mode)

      设置输出模式 Setup ouput mode
      Specified by:
        `setOutputMode` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `mode` - 0:扫描到光标位置(scan content to cursor) 1:剪切板(clipboard) 2:广播(broadcast) 3:模拟键盘(analog keyboard)

    - #### setScanOutTime

          public void setScanOutTime(android.content.Context context,
                                     int time)

      设置超时时间 Setup overtime duration
      Specified by:
        `setScanOutTime` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `time` - 超时时间，单位秒 time overtime time, unit is second

    - #### setScanResultBroadcast

          public void setScanResultBroadcast(android.content.Context context,
                                             java.lang.String broadcastAction,
                                             java.lang.String extraName)

      设置接收扫描数据的广播 Setup broad cast of received scanning data
      Specified by:
        `setScanResultBroadcast` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `broadcastAction` - 接收扫描数据的action
        `extraName` - Intent返回的扩展数据项目名称

    - #### openKeyboardHelper

          public void openKeyboardHelper(android.content.Context context)

      打开键盘助手功能总开关 Switch on main function switch of keyboardemulator
      Specified by:
        `openKeyboardHelper` in interface `IBarcodeUtility`
      Parameters:
        `context` -

    - #### closeKeyboardHelper

          public void closeKeyboardHelper(android.content.Context context)

      关闭键盘助手功能总开关 Switch off main function switch of keyboardemulator
      Specified by:
        `closeKeyboardHelper` in interface `IBarcodeUtility`
      Parameters:
        `context` -

    - #### enablePlaySuccessSound

          public void enablePlaySuccessSound(android.content.Context context,
                                             boolean isSuccessSound)

      是否播放成功的提示音 whether playing notification when scanning success.
      Specified by:
        `enablePlaySuccessSound` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `isSuccessSound` - true:播放成功提示音,false:不播放成功提示音 true: enable false:disable

    - #### enablePlayFailureSound

          public void enablePlayFailureSound(android.content.Context context,
                                             boolean isFailureSound)

      扫描失败是否播放提示音 whether playing notification when scanning failure.
      Specified by:
        `enablePlayFailureSound` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `isFailureSound` - true:播放失败提示音,false:不播放失败提示音 true: enable false:disable

    - #### enableVibrate

          public void enableVibrate(android.content.Context context,
                                    boolean isVibrate)

      扫描成功是否震动提示 whether vibrating when scanning success
      Specified by:
        `enableVibrate` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `isVibrate` - true:震动,false:不震动 true: enable false:disable

    - #### enableEnter

          public void enableEnter(android.content.Context context,
                                  boolean isEnter)

      是否启用回车 Whether enable Enter function
      Specified by:
        `enableEnter` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `isEnter` - true: 启用回车 false:不启用回车 true: enable false:disable

    - #### enableTAB

          public void enableTAB(android.content.Context context,
                                boolean isTab)

      是否启用TAB Whether enable TAB function
      Specified by:
        `enableTAB` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `isTab` - true: 启用回车 false:不启用回车 true: enable false:disable

    - #### setSuffix

          public void setSuffix(android.content.Context context,
                                java.lang.String suffix)

      设置后缀 Setup suffix
      Specified by:
        `setSuffix` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `suffix` - 后缀字符

    - #### setPrefix

          public void setPrefix(android.content.Context context,
                                java.lang.String prefix)

      设置前缀 Setup prefix
      Specified by:
        `setPrefix` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `prefix` - 前缀字符

    - #### interceptTrimLeft

          public void interceptTrimLeft(android.content.Context context,
                                        int num)

      截取左边字符串数量 Capture left side charactor string amount
      Specified by:
        `interceptTrimLeft` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `num` - 左边截取的字符数量

    - #### interceptTrimRight

          public void interceptTrimRight(android.content.Context context,
                                         int num)

      截取右边字符串数量 Capture right side charactor string amount
      Specified by:
        `interceptTrimRight` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `num` - 右边截取的字符数量

    - #### filterCharacter

          public void filterCharacter(android.content.Context context,
                                      java.lang.String chars)

      过滤字符串 Filter charactor string
      Specified by:
        `filterCharacter` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `chars` - 过滤的字符

    - #### setBarcodeEncodingFormat

          public void setBarcodeEncodingFormat(android.content.Context context,
                                               int format)

      设置条码编码格式 Setup barcode coding format
      Specified by:
        `setBarcodeEncodingFormat` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `format` - 0: Default 1: ASCII 2:GB2312 3:UTF8 4:Unicode 10:GBK, 11:GB18030

    - #### enableContinuousScan

          public void enableContinuousScan(android.content.Context context,
                                           boolean isContinuous)

      启用连续扫描 Enable continuous scan
      Specified by:
        `enableContinuousScan` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `isContinuous` - true: 连续扫描 false：单次扫描 true: enable false：disable

    - #### setContinuousScanIntervalTime

          public void setContinuousScanIntervalTime(android.content.Context context,
                                                    int intervalTime)

      设置连续扫描间隔时间 Setup continuous scanning duration
      Specified by:
        `setContinuousScanIntervalTime` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `intervalTime` - 间隔时间，单位毫秒 interval Time, (unit: millisecond)

    - #### setContinuousScanTimeOut

          public void setContinuousScanTimeOut(android.content.Context context,
                                               int timeOut)

      设置连续扫描超时时间 Setup continuous scanning overtime duration
      Specified by:
        `setContinuousScanTimeOut` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `timeOut` - 超时时间，单位秒 time Out(unit:second)

    - #### setScanFailureBroadcast

          public void setScanFailureBroadcast(android.content.Context context,
                                              boolean enable)

      扫描失败是否发送广播 Send broadcast when scanning failure.
      Specified by:
        `setScanFailureBroadcast` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `enable` - true:发送 false：不发送

    - #### setReleaseScan

          public void setReleaseScan(android.content.Context context,
                                     boolean enable)

      松开扫描按键是否停止扫描 loose scanning button to stop scanning or not
      Specified by:
        `setReleaseScan` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `enable` - true:停止扫描 false：不停止扫描

    - #### setParam_zebra

          public void setParam_zebra(android.content.Context context,
                                     int paramId,
                                     int paramValue)

      设置斑马扫描头参数,扫描头上电之后设置一次即可,扫描头断电之后失效。(备注：键盘助手v2.2.0.3 之后的版本才支持)
      Specified by:
        `setParam_zebra` in interface `IBarcodeUtility`
      Parameters:
        `context` -
        `paramId` - id
        `paramValue` - value